home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / EV61.ARJ / EV.ASM < prev    next >
Assembly Source File  |  1996-07-21  |  9KB  |  202 lines

  1. ; Egt view V6.1
  2. ; Copyright 1996 by Beowulf Shaeffer
  3. ; Member of The Powerdrome's Beta Zone
  4. ; WASM sourcefile
  5.  
  6. start           proc    near    ; use only short jumps
  7.                 mov     ax,ds   
  8.                 mov     es,ax   ; copy ds into es, the extra segment
  9.  
  10. check_vga       mov     ax,1a00h        ; Setup VGA check
  11.                 int     10h
  12.                 cmp     bl,7            ; Analog?
  13.                 jb      no_vga
  14.                 cmp     bl,8            ; Monochrome?
  15.                 ja      no_vga
  16.  
  17. start_proc      sub     bh,bh   ; make bh=0
  18.                 MOV     BL,[com_line]           ; Load BL with first COM_LINE byte.
  19.                 cmp     bl,0
  20.                 je      no_opts
  21.  
  22. ; Added to enable the .EGT extention.
  23.                 mov     al,[bx+com_line-3]
  24.                 cmp     al,'.'
  25.                 jne     addit
  26.                 mov     byte [bx+com_line+1],0
  27.                 jmp     open
  28.  
  29. addit           mov     byte [bx+com_line+1],'.'        ; add .egt +chr$(0)
  30.                 mov     byte [bx+com_line+2],'e'        ; to commandline
  31.                 mov     byte [bx+com_line+3],'g'
  32.                 mov     byte [bx+com_line+4],'t'
  33.                 MOV     byte [BX+com_line+5],0
  34.  
  35. open            MOV     AX,3D82H        ; Prepare int 21h function 3dh
  36.                 MOV     DX,com_line+2   ; Point second byte at commandline
  37.                 INT     21H             ; Execute OPEN function.
  38.                 JC      no_file         ; Error? > jump
  39.                 MOV     FILE_HANDLE,AX  ; Put AX in variable FILE_HANDLE.
  40.  
  41. mcga            mov     ax,0013h        ; Prepare Set Mode 13h (MCGA)
  42.                 int     10h             ; Execute mode instruction
  43.         
  44. palette         pop     dx              ; Restore registers after 32 bit
  45.                 pop     cx              ; filepointer operations
  46.                 pop     bx
  47.                 pop     ax
  48.  
  49.                 mov     bx,file_handle  ; Put filehandle in bx
  50.                 mov     dx,offset buffer; First adress of buffer in dx
  51.                 MOV     CX,768          ; 3 x 256 palette bytes of size
  52.                 MOV     AX,3F00H        ; Prepare read 768 bytes function
  53.                 INT     21H             ; Execute READ function.
  54.                 cmp     ax,768          ; Load successful?
  55.                 jne     close           ; No? -> go to close
  56.  
  57. pallettje       mov     ax,1012h        ; Prepare a block DAC setting
  58.                 sub     bx,bx           ; make bx=0
  59.                 mov     cx,256          ; Number of (RGB) registers = 256
  60.                 mov     dx,offset buffer; Put first adress of buffer in dx
  61.                 int     10h             ; Execute instruction   
  62.                 jmp     regel
  63.  
  64. no_opts         mov     dx,offset noopts_msg
  65.                 jmp     display1
  66.  
  67. no_vga          mov     dx,offset novga_msg    ; Point to string with dx
  68.                 jmp     display1
  69.  
  70. no_file         mov     dx,offset nofile_msg    ; Point to string with dx
  71.  
  72. display1        mov     ah,9h           ; Prepare display string function
  73.                 int     21h             ; Execute
  74.  
  75. stopje          MOV     AX,4C00H        ; Return to DOS function setup
  76.                 INT     21H             ; Do it
  77.  
  78. pall            jmp     palette         ; sub-jump to palette
  79.  
  80. CLOSE           MOV     AH,3EH          ; Load required functionnumber
  81.                 INT     21H             ; Execute close function
  82.  
  83. exit_1          mov     ax,0003h        ; Prepare setmode 3 (TEXTmode)
  84.                 int     10h             ; execute it
  85.                 jmp     stopje
  86.  
  87. regel           push    ds              ; Save data segment
  88.                 mov     bx,file_handle  ; Put file-handle in bx
  89.                 sub     dx,dx           ; First destination adress dx=0000
  90.                 mov     ax,0a000h       ; Set datasegment to a000h
  91.                 mov     ds,ax           ; (beginning of MCGA VGA-RAM)
  92.                 
  93.                 MOV     CX,0fa00h       ; Size is 200 x 320 = fa00h bytes
  94.                 MOV     AX,3F00H        ; Load picturepart of EGT file
  95.                 INT     21H             ; Execute it
  96.                 pop     ds
  97.  
  98. keybd           push    ax              ; Save registers before 32 bit
  99.                 push    bx              ; filepointer operations
  100.                 push    cx
  101.                 push    dx
  102.  
  103. kwait           sub     ax,ax           ; prepare wait for keyboard function
  104.                 int     16h             ; execute int 16h
  105.                 
  106.                 cmp     ax,011bh        ; <ESC> pressed?
  107.                 je      exit_2
  108.                 
  109.                 cmp     ax,4700h        ; <HOME> pressed?
  110.                 je      f_begin2
  111.                 cmp     ax,0837h        ; <7> pressed? (same action)
  112.                 je      f_begin2                
  113.                 
  114.                 cmp     ax,4f00h        ; <END> pressed?
  115.                 je      f_end
  116.                 cmp     ax,0231h        ; <1> pressed? (same action)
  117.                 je      f_end                
  118.                 
  119.                 cmp     ax,4b00h        ; <<-> pressed? (left arrow)
  120.                 je      f_terug
  121.                 cmp     ax,0534h        ; <4> pressed? (same action)
  122.                 je      f_terug              
  123.                 cmp     ax,4800h        ; <^> pressed? (up arrow)
  124.                 je      f_terug
  125.                 cmp     ax,0938h        ; <8> pressed? (same action)
  126.                 je      f_terug              
  127.                 
  128.                 cmp     ax,4d00h        ; <->> pressed? (right arrow)
  129.                 je      pall
  130.                 cmp     ax,0736h        ; <6> pressed? (same action)
  131.                 je      pall   
  132.                 cmp     ax,5000h        ; <v> pressed? (down arrow)
  133.                 je      pall
  134.                 cmp     ax,0332h        ; <2> pressed? (same action)
  135.                 je      pall         
  136.                 
  137.                 jmp     kwait           ; wait for another key
  138.  
  139. f_end           mov     al,2            ; set end of file function
  140.                 xor     cx,cx           ; offset high=0
  141.                 xor     dx,dx           ; offset low=0
  142.                 call    f_pointer       ; get file size into dx:ax
  143.                 mov     cx,dx           ; copy them to cx:dx
  144.                 mov     dx,ax
  145.                 sub     dx,0fd00h       ; subtract pictureblock-size
  146.                 jc      carry           ; low 16 bits carry?
  147. jawel           mov     al,0            ; set filepointer function
  148.                 call    f_pointer       ; set filepointer
  149.                 jmp     palette         ; get picture
  150. carry           dec     cx              ; high 16 bits decrease after carry
  151.                 jmp     jawel
  152.  
  153. exit_2          jmp     exit_1          ; sub-jump to exit_1
  154.  
  155. f_begin2        jmp     f_begin         ; sub-jump to f_begin
  156.  
  157. f_terug         mov     al,1            ; get current pointer
  158.                 xor     cx,cx           ; offset high=0
  159.                 xor     dx,dx           ; offset low=0
  160.                 call    f_pointer       ; current pointer is in dx:ax
  161.                 and     dx,dx
  162.                 jz      f_begin2        ; check if current is first picture
  163.                 mov     cx,dx
  164.                 mov     dx,ax
  165.                 
  166.                 sub     dx,0fd00h       ; begin filepointer-1 block
  167.                 jc      carry2
  168.                 jmp     bloktwee
  169. carry2          dec     cx
  170.                 
  171. bloktwee        sub     dx,0fd00h
  172.                 jc      carry3
  173.  
  174. jawel3          mov     al,0
  175.                 call    f_pointer
  176.                 jmp     palette         ; now filepointer is set 2 picture-
  177.                                         ; blocks backwards.
  178.  
  179. carry3          dec     cx
  180.                 jmp     jawel3
  181.  
  182. f_begin         mov     al,0            ; point to begin+offset
  183.                 xor     cx,cx           ; offset high=0
  184.                 xor     dx,dx           ; offset low=0
  185.                 call    f_pointer
  186.                 jmp     palette         ; show first picture in .egt file
  187.  
  188. f_pointer       mov     ah,42h          ; setpointer function init
  189.                 mov     bx,file_handle  ; for file_handle
  190.                 int     21h             ; execute
  191.                 ret
  192.  
  193.                 endp     
  194.  
  195. nofile_msg      db      'Sorry, I can',39,'t find that file.',13,'$'
  196. novga_msg       db      'I can',39,'t find a VGA adapter!',13,'$'
  197. noopts_msg      db      'Egt Viewer 6.1 Copyright ',39,'96 by Beowulf Shaeffer',13,10
  198.                 db      'To view DEMO.EGT type EV DEMO',13,'$'
  199. FILE_HANDLE     DW      ?
  200. BUFFER          DB      768 * ?                 ; use 768 bytes as buffer
  201. com_line        equ     80h
  202.